
 
export default function countReducer(state={count:0},action) {
    
    switch (action.type) {
        case 'add':
                return {
                    ...state,
                    count:state.count+action.payload
                }
            
    
        default:
            return state
    }

    
}

    export const asyncAdd=(n)=>(dispatch)=>{
        setTimeout(() => {
            dispatch({
                type:"add",
                payload:n       
            })
        }, 2000);

    }
